package com.cndatacom.eweb.hibernate.ext;

import java.util.List;

import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.type.Type;

public class BitAndFunction extends StandardSQLFunction implements SQLFunction {

	public BitAndFunction(String name) {
		super(name);
	}

	public BitAndFunction(String name, Type typeValue) {
		super(name, typeValue);
	}
	
	@SuppressWarnings("unchecked")
	public String render(List args) {
		if (args.size() != 2){
			throw new IllegalArgumentException("the function must be passed 2 arguments");
		}
		StringBuffer buffer = new StringBuffer(args.get(0).toString());
		buffer.append(" & ").append(args.get(1));
		return buffer.toString();
	}
	
}

